<template>
   <div class="right-form">
      <div class="bg">
          <input class="name" type="text" v-model="username" placeholder="请输入您的姓名">
          <input type="text" v-model="phone" placeholder="请输入您的电话号码">
          <div class="submit" @click="submit()"></div>
      </div>
        
    </div>
</template>

<script>
import { mapState } from 'vuex'
import axios from 'axios'

export default {
  name: 'news-list-right-form',
  components:{
   
  },
  props:{
     
     
  },
  data () {
    return {
        username:'',
        phone:'',
        message:'嘉宝PC官网新闻页面',
        description:'嘉宝PC官网新闻页面',
        local:'嘉宝PC官网新闻页面'
    }
  },
  watch:{
    data(){
       
    }
  },
  computed:{
        ...mapState(['baseUrl'])
    },
  mounted() {
 
    
  },
  methods:{
       submit(){
            this.sendForm();
        },
        sendForm (){
            axios.get(this.baseUrl+'cms/joinAdd',
            {
                params:{
                    username:this.username,
                    phone:this.phone,
                    message:this.message,
                    description:this.description,
                    local:this.local
                }
            })
            .then(this.sendSucc)
        },
        sendSucc(response){
            //    console.log(response)
            const h = this.$createElement;
            if(response.data.errno===0){

                
                this.$notify({
                    title: '成功提醒',
                    type: 'success',
                    message: h('i', { style: 'color: teal'}, '留言成功，稍后客服会给你回复，请耐心等待')
                });
                this.getJoincount();

            }else if(response.data.errno===1){
                
                this.$notify.error({
                    title: '错误提醒',
                    message: h('i', { style: 'color: teal'}, '该手机号已提交过留言，请等待客服回复')
                });
            }
        }
  }
 
  
}
</script>

<style lang="stylus" scoped>
@import "~styles/varibles.styl"
@import "~styles/mixins.styl"
img 
    width 100%
.bg
    background url('~@/assets/news-list/formbg.png') no-repeat center center 
    width 282px
    height 360px
    overflow hidden
input,.submit 
    width 262px
    height 40px
    text-indent 10px
    margin 10px auto
    display block
.name 
    margin-top 170px
</style>
